#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 7;
int a[N];
int n;
int cnt[10000 + 7];
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  n = unique(a, a + n + 2) - a;
  for (int i = 1; i <= n - 1; ++i) {
    if (a[i - 1] < a[i] && a[i] > a[i + 1]) {
      cnt[a[i]]++;
    }  // convex
    else if (a[i - 1] > a[i] && a[i] < a[i + 1]) {
      cnt[a[i]]--;
    }  // concave
  }
  int sum = 0;
  int ans = 0;
  for (int i = 10001; i >= 0; --i) {
    sum += cnt[i];
    ans = max(sum, ans);
  }
  cout << ans << endl;
}
